#include<stdio.h>

#define N 105
struct node
{
    int child[N];
    int k;
} s[N];
int que[N * N];

void init()
{
    int i;
    for(i = 0;i < N;i++)
        s[i].k = 0;
}

int main()
{
    int n, m, i, j, l, r, count, k, t;
    while(scanf("%d%d", &n, &m) != EOF)
    {
        init();
        for(t = 0;t < m;t++)
        {
            scanf("%d", &i);
            scanf("%d", &s[i].k);
            for(j = 0;j < s[i].k;j++)
            {
                scanf("%d", &s[i].child[j]);
            }
        }
        que[0] = 1;
        k = 1;
        for(l = 0, r = 1, t = 0;l < k;r = k, t++)
        {
            count = 0;
            //printf("%d %d\n",l,r);
            for(;l < r;l++)
            {
                i = que[l];
                if(!s[i].k)count++;
                for(j = 0;j < s[i].k;j++)
                    que[k++] = s[i].child[j];

            }
            if(t)printf(" %d", count);
            else
                printf("%d", count);
        }
        printf("\n");

    }
    return 0;
}


/*
#include<stdio.h>

int main()
{
    int N, M, n, m, t,i,j,max_level=0;
    int a[105], s[105];

    scanf("%d %d", &N, &M);
    for(i = 0;i < 105;++i)
    {
        a[i]=0;
        s[i]=0;
    }

    for(i = 1;i <= M;++i)
    {
        scanf("%d%d", &m, &n);
        if(i == 1)
        {
            a[m] = 1;
        }

        for(j = 1;j <= n;++j)
        {
            scanf("%d", &t);
            a[t] = a[m] + 1;
        }
        a[m] = 110;
    }

    for(i = 1;i <= N;++i)
    {
        if(a[i] < 110)
        {
            s[a[i]]++;
            if(a[i] > max_level)
            {
                max_level=a[i];
            }
        }

    }

    for(i = 1;i <= max_level;++i)
    {
        printf("%d", s[i]);
        if(i < max_level)
        {
            printf(" ");
        }
    }
    return 0;
}
*/
